﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



using CRM.Entity;
using CRM.BLL;
using DP.Web.UI;
using DP.Common;


namespace CRM.Web.Pop
{
    public partial class BlackApply : Common.PageBase
    {

        T_BLACKAPPLY_BLL bll = new T_BLACKAPPLY_BLL();
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            PageHelper.SetPrePageUrl(this.Page); 
            if (PageHelper.GetQueryString(this.Page, "OPENTYPE") == "NEWPAGE")
            {
                btnCancel.Value = "关闭";
                btnCancel.Attributes["onclick"] = "closeSelf();";
            }
            else
            {
                PageHelper.SetGoBackUrl(this.Page, btnCancel, StaticConstant.NotBackUrl);
            }

        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pageDataInit();
            }
        }



        private void pageDataInit()
        {
            PageHelper.GetUrlQueryToControl(this.Page);
            


        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            string _autoid = String.IsNullOrEmpty(Request.QueryString["AUTOID"]) ? "" : Request.QueryString["AUTOID"].Trim();


            T_BLACKAPPLY_Entity entity = new T_BLACKAPPLY_Entity();
            PageHelper.GetControlValue<T_BLACKAPPLY_Entity>(this.Page, ref entity);
            entity.CREATEPEOPLEID = _userLoginInfo.UserEntity.USERID;
            entity.CREATETIME = DateTime.Now;
            entity.CREATEPEOPLE = _userLoginInfo.UserEntity.USERNAME;
            entity.CALLTYPE = PageHelper.GetQueryString(this.Page, "CALLTYPE");
            entity.CALLID = PageHelper.GetQueryString(this.Page, "CALLID");
            entity.RECORDCODE = PageHelper.GetQueryString(this.Page, "RECORDCODE");
            entity.CUSTOMERCODE = PageHelper.GetQueryString(this.Page, "CUSTOMERCODE");
            entity.CUSTOMERID = PageHelper.GetQueryString(this.Page, "CUSTOMERID");
            entity.STATUS = ((int)BlackApplyStatus.待审核);
            entity.BUSINESSDIVISIONCODE = _userLoginInfo.UserEntity.BUSINESSDIVISIONCODE;
            entity.BUSINESSDIVISIONID = _userLoginInfo.UserEntity.BUSINESSDIVISIONID;
            entity.BUSINESSDIVISIONNAME = _userLoginInfo.UserEntity.BUSINESSDIVISIONNAME;

            long rel = bll.Insert(entity);
            if (rel > 0)
            {
                PageHelper.ExecuteJS("alert('申请成功！'); closeSelf();");
                //PageHelper.ShowMessage(this.Page, "添加成功！", "list.aspx");
            }
            else
            {
                PageHelper.ShowMessage(this.Page, "申请失改！");
            }

            
        }
    }
}
